package com.example.shixunandjavagotoyangchen.Eternity.YinDaoActivity;

import android.content.Intent;
import android.os.Handler;
import android.os.Message;
import android.widget.ImageView;

import androidx.annotation.NonNull;

import com.blankj.utilcode.util.ToastUtils;
import com.bumptech.glide.Glide;
import com.example.modelviewpresenter.View.BasterFragment;
import com.example.shixunandjavagotoyangchen.Eternity.YeMianActivity.YeMianfengzhuangActivity;
import com.example.shixunandjavagotoyangchen.R;

import java.util.Timer;
import java.util.TimerTask;


public class BlankFragmentYindao3 extends BasterFragment {
    int shijian = 5;
    Timer timer;
    public Handler handler = new Handler() {
        @Override
        public void handleMessage(@NonNull Message msg) {
            super.handleMessage(msg);
            //等待接收消息
            if (msg.what == 150712) { //开始倒计时

                timer = new Timer();
                timer.schedule(new TimerTask() {
                    @Override
                    public void run() {
                        handler.sendEmptyMessage(666);
                    }
                }, 0, 1000);


            }
            if (msg.what == 666) {
                if (shijian == 0) {
                    timer.cancel();
                    //跳转
                    Intent intent =new Intent(getActivity(), YeMianfengzhuangActivity.class);
                    startActivity(intent);

                    getActivity().finish();
                } else {
                    shijian--;
                    ToastUtils.showShort("" + shijian);
                }

            }
        }
    };
    private ImageView imgerview1;

    @Override
    public int BandLayout() {
        return R.layout.fragment_blank_fragment_yindao3;
    }

    @Override
    public void initView() {

        imgerview1 = (ImageView) findViewById(R.id.imgerview1);
    }

    @Override
    public void initDate() {
        Glide.with(this).load(R.mipmap.dongtu5).into(imgerview1);
    }
}
